<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>booleam</title>
</head>
<body>
    <!-- booleam -->
    <script>
        // 隐式类型转换
        var booleanValue = !0;
        console.log('typeof(!0) = ' + typeof booleanValue + ' ' + booleanValue);
        booleanValue = !1000;
        console.log('typeof(!1000) = ' + typeof booleanValue + ' ' + booleanValue);
        booleanValue = !!1000;
        console.log('typeof(!!1000) = ' + typeof booleanValue + ' ' + booleanValue);

        // 显示类型转换
        booleanValue = Boolean(0); // 等价于!0
        console.log('typeof(Boolean(0)) = ' + typeof booleanValue + ' ' + booleanValue);
        booleanValue = Boolean(1000);
        console.log('typeof(Boolean(1000)) = ' + typeof booleanValue + ' ' + booleanValue);
        booleanValue = Boolean(undefined);
        console.log('typeof(Boolean(undefined)) = ' + typeof booleanValue + ' ' + booleanValue);
        booleanValue = Boolean(null);
        console.log('typeof(Boolean(null)) = ' + typeof booleanValue + ' ' + booleanValue);
        booleanValue = Boolean(NaN);
        console.log('typeof(NaN)) = ' + typeof booleanValue + ' ' + booleanValue);
        booleanValue = Boolean('');
        console.log('typeof(Boolean(\'\') = ' + typeof booleanValue + ' ' + booleanValue);
    </script>
</body>
</html>